// 01序列问题
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();

        String str = sc.next();
        int[] s = new int[n];
        int sum=0;
        for (int i=0;i<n;i++){
            s[i]= str.charAt(i)-'0';
            sum+=s[i];
        }


        //1更多
        if(sum>=n/2){

            str = str.replaceAll("000","")
                    .replaceAll("001","")
                    .replaceAll("100","")
                    .replaceAll("010","");
            int sum1 = 0;
            for (int i=0;i<str.length();i++){
                s[i]= str.charAt(i)-'0';
                sum1+=s[i];
            }
            System.out.println(2*sum1-str.length());
        }else {//0更多
            str = str.replaceAll("111","")
                    .replaceAll("110","")
                    .replaceAll("011","")
                    .replaceAll("101","");
            int sum1 = 0;
            for (int i=0;i<str.length();i++){
                s[i]= str.charAt(i)-'0';
                sum1+=s[i];
            }
            System.out.println(str.length()-2*sum1);
        }



    }
}
